package com.eystar.ext.plugin.crate.db;

import java.sql.Connection;

import org.apache.commons.pool2.impl.GenericObjectPool;

public class CratePool {

	private static GenericObjectPool<Connection> pool=null;
	
	static {
		pool=new GenericObjectPool<Connection>(new CratePoolFactory());
		pool.setMaxTotal(50);//开启50个连接池
	}
	
	public static Connection getConnection() throws Exception {
		return pool.borrowObject();
	}
	
	public static void returnObject(Connection connection){
		pool.returnObject(connection);
	}
	
	public static GenericObjectPool<Connection> getPool(){
		return pool;
	}
}
